﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Windows;
using QFTMCO;
using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using ReflectionStudio.Core.Helpers;
using INTEX.DataBase;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for SETUPABON.xaml
    /// </summary>
    public partial class SETUPRAWYARN : DocumentBase
    {
        public SETINTEXDB SetData
        {
            get
            {
                return (SETINTEXDB)TryFindResource("SetData");
            }
        }
        DataSet setYarn = new DataSet();
        QFTMCOData m_Data;
        public OracleConnection OracleDB;
        public OracleCommand orlReadCommand = new OracleCommand();
        public IntexReptServBLClient proxy;
        private Dictionary<string, object> dicParamater;
        public SETUPRAWYARN()
        {
            InitializeComponent();

            this.Name = "纱价维护";
            this.Title = "纱价维护";
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public override void SetUp(Dictionary<string, object> dicParamater)
        {
            try
            {
                using (new LongOperation(this, "读取符合条件的记录"))
                {
                    base.SetUp(dicParamater);
                    InitializeComponent();
                    this.dicParamater = dicParamater;
                    OracleDB = (OracleConnection)dicParamater["OracleDB"];
                    proxy = (IntexReptServBLClient)dicParamater["proxy"];
                    m_Data = new QFTMCOData(OracleDB, proxy);
                    SetData.Clear();
                    setYarn = m_Data.LoadYarnPrice();
                    SetData.Merge(setYarn);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void btnYnLoad_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SetData.YARNPRICE.Clear();
                SetData.Merge(m_Data.LoadSetYarnPrice());
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void btnYnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                m_Data.SaveYarnPrice(SetData.YARNPRICE);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void btnYPStartXls_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
